using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL {

/// <summary>
/// The AddressTypeCodeTableManager class is responsible for managing BO.AddressTypeCodeTable objects in the system.
/// </summary>
[DataObjectAttribute()]
public class AddressTypeCodeTableManager
  {

#region "Public Methods"

/// <summary>
/// Gets a list with all AddressTypeCodeTable objects in the database.
/// </summary>
/// <returns>A list with all AddressTypeCodeTable from the database when the database contains any, or null otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, true)]
public static AddressTypeCodeTableList GetList(){
return AddressTypeCodeTableDB.GetList();
}

/// <summary>
/// Gets a single AddressTypeCodeTable from the database without its data.
/// </summary>
/// <param name="addressTypeCode">The AddressTypeCode of the AddressTypeCodeTable in the database.</param>
/// <returns>A AddressTypeCodeTable object when the AddressTypeCode exists in the database, or <see langword="null"/> otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static AddressTypeCodeTable GetItem(short addressTypeCode){
return GetItem(addressTypeCode, false);
}

/// <summary>
/// Gets a single AddressTypeCodeTable from the database.
/// </summary>
/// <param name="addressTypeCode">The AddressTypeCode of the AddressTypeCodeTable in the database.</param>
/// <param name="getAddressTypeCodeTableRecords">Determines whether to load all associated AddressTypeCodeTable records as well.</param>
/// <returns>
/// A AddressTypeCodeTable object when the AddressTypeCode exists in the database, or <see langword="null"/> otherwise.
/// </returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static AddressTypeCodeTable GetItem(short addressTypeCode, bool getAddressTypeCodeTableRecords){
AddressTypeCodeTable myAddressTypeCodeTable = AddressTypeCodeTableDB.GetItem(addressTypeCode);
return myAddressTypeCodeTable;
}

/// <summary>
/// Saves a AddressTypeCodeTable in the database.
/// </summary>
/// <param name="myAddressTypeCodeTable">The AddressTypeCodeTable instance to save.</param>
/// <returns>The new AddressTypeCode if the AddressTypeCodeTable is new in the database or the existing AddressTypeCode when an item was updated.</returns>
[DataObjectMethod(DataObjectMethodType.Update, true)]
public static short Save(AddressTypeCodeTable myAddressTypeCodeTable){
using (TransactionScope myTransactionScope = new TransactionScope()){
short addressTypeCodeTableAddressTypeCode = AddressTypeCodeTableDB.Save(myAddressTypeCodeTable);

//  Assign the AddressTypeCodeTable its new (or existing AddressTypeCode).
myAddressTypeCodeTable.AddressTypeCode = addressTypeCodeTableAddressTypeCode;

myTransactionScope.Complete();

return addressTypeCodeTableAddressTypeCode;
}
}

/// <summary>
/// Deletes a AddressTypeCodeTable from the database.
/// </summary>
/// <param name="myAddressTypeCodeTable">The AddressTypeCodeTable instance to delete.</param>
/// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public static bool Delete(AddressTypeCodeTable myAddressTypeCodeTable){
return AddressTypeCodeTableDB.Delete(myAddressTypeCodeTable.AddressTypeCode);
}

#endregion

}

}
